<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author: LJQ <liujiqi@etrol.com> 
// +----------------------------------------------------------------------

namespace app\common\controller;
use think\Controller;

class Base  extends Controller {

	protected $url;
	protected $request;
	protected $module;
	protected $controller;
	protected $action;

	public function _initialize() {
		/* 读取数据库中的配置 */
// 		$config = cache('db_config_data');
// 		if (!$config) {
// 			$config = model('Config')->lists();
// 			cache('db_config_data', $config);
// 		}
// 		config($config);
		$this->requestInfo();
	}
	
	//request信息
	protected function requestInfo() {
		$this->param = $this->request->param();
		defined('MODULE_NAME') or define('MODULE_NAME', $this->request->module());
		defined('CONTROLLER_NAME') or define('CONTROLLER_NAME', $this->request->controller());
		defined('ACTION_NAME') or define('ACTION_NAME', $this->request->action());
		defined('IS_POST') or define('IS_POST', $this->request->isPost());
		defined('IS_GET') or define('IS_GET', $this->request->isGet());
		defined('IS_AJAX') or define('IS_AJAX',$this->request->isAjax());
		$this->url = strtolower($this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action());
	}

    /**
     * 快捷返回json信息
     */
    protected function ajaxReturn($data=[], $status = 1, $info = 'callback') {

        return json(['code' => $status, 'message' => $info, 'data' =>  $data]);
    }




}
